﻿using CommonEntity;
using Enyim.Caching;
using Microsoft.AspNetCore.Mvc;
using NetCroe6WebAPITestOneBusiness;

namespace NetCroe6WebAPITestOne.Controllers
{
    [ApiController]
    [Route("MemcachedExp")]
    [Produces("application/json")]
    public class MemcachedExpController : ControllerBase
    {
        MemcachedExpBusiness _memcachedExpBusiness;

        public MemcachedExpController(MemcachedExpBusiness memcachedExpBusiness)
        {
            _memcachedExpBusiness = memcachedExpBusiness;
        }

        /// <summary>
        /// 设置/更新memcached值
        /// </summary>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        [HttpGet("SetMemcachedValue")]
        public ViewModelBase SetMemcachedValue(string key,string value) {
            return _memcachedExpBusiness.SetMemcachedValue(key, value);
        }


        /// <summary>
        /// 获取memchached数据
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        [HttpGet("GetMemcachedValue")]
        public ViewModelBase GetMemcachedValue(string key) {
            return _memcachedExpBusiness.GetMemcachedValue(key);
        }
    }
}
